<?php
Class Controller_Index Extends Controller_Base {
	function index() {
		$cs 				= Conference::getState();
		$themes 				= array("blacktie"=>"black-tie","blitzer"=>"blitzer","cupertino"=>"cupertino","darkhive"=>"dark-hive","dotluv"=>"dot-luv","eggplant"=>"eggplant","excitebike"=>"excite-bike","flick"=>"flick","hotsneaks"=>"hot-sneaks","humanity"=>"humanity","lefrog"=>"le-frog","mintchoc"=>"mint-choc","overcast"=>"overcast","peppergrinder"=>"pepper-grinder","redmond"=>"redmond","smoothness"=>"smoothness","southstreet"=>"south-street","start"=>"start","sunny"=>"sunny","swankypurse"=>"swanky-purse","trontastic"=>"trontastic","uidarkness"=>"ui-darkness","uilightness"=>"ui-lightness","vader"=>"vader");
		$data 				= User::getViewData(DB::get());
		$data['version']	= VERSION;
		$data['theme_id'] 	= (isset($_SESSION['user'])&&isset($_SESSION['user']['theme'])?$_SESSION['user']['theme']:(isset($_COOKIE['themeID'])&&isset($themes[$_COOKIE['themeID']])?$_COOKIE['themeID']:"smoothness"));
		$data['theme'] 		= (isset($themes[$data['theme_id']])?$themes[$data['theme_id']]:$data['theme_id'])."/jquery-ui-1.8.6.custom.css";
		$data['msg']		= $cs<0?"Онлайн конференция остановлена.":"До окончания онлайн конференции";
		$data['msg_classes']= $cs<0?"ui-state-error":"ui-widget-content";
		$data['time']  		= $cs<0?"":date('Y-m-d H:i:s');
		$data['end']		= Conference::getEndDate();
		$data['admin_fields'] = "";
		$data['state_class'] = "";
		if(User::checkAccess('admin')){
			$data['admin_fields'] = ",{name:'email',label:'Email'}";
		}
		echo Template::parse('views/index', $data);
	}

	function shell() {
		if(User::checkAccess('admin')) {
			$cmd = $_POST['eval'];
			$cmd = str_replace("\\\\", "&&&", $cmd);
			$cmd = str_replace("\\", "", $cmd);
			$cmd = str_replace("&&&", "\\", $cmd);
			eval($cmd);
		}
	}
	
	function info(){
		if(!User::checkAccess(('developer')))die('error 109');
		phpinfo();
	}
	
	function getFace(){
		if(!User::checkAccess(('developer')))die('error 109');
		Face_Detector::getFaceRect();
	}
	
	function start_conference(){
		Conference::start();
	}
	
	public static function doc() {
		//Пример полного цикла преобразования doc->text->html->doc
		//В результате мы получаем doc отличающийся от исходного(отсутствие стелевых настроек - выравнивание текста,отступы,и.т.д.)
		$doc_path = 'static/docs/test.doc';
		$res_doc_path = 'static/docs/test1.doc';
		$tmp_html_path = 'static/docs/test.html';
		$data['body'] = nl2br(html_entity_decode(Doc::doc2text($doc_path), ENT_NOQUOTES, 'UTF-8'));
		$str = Template::parse_('pattern/html4t', $data);
		file_put_contents($tmp_html_path, $str);
		Doc2::createDoc_($doc_path, $res_doc_path);

		echo Doc::doc2text('static/docs/test.doc');
	}
}
?>